import IntegrationTable, {
	IntegrationTableProps,
} from "@/components/IntegrationTable";
import { ProColumns } from "@ant-design/pro-table";
import React, { useEffect } from "react";

// @page 商家
const Business: React.FC<any> = () => {
	// 组件是否已经卸载
	let isUnMounted = false;
	// 表格项
	const columns: ProColumns[] = [
		{
			title: "日期",
			dataIndex: "time",
			valueType: "dateRange",
			hideInTable: true,
			search: {
				transform: (value: any) => ({
					startTime: value[0],
					endTime: value[1],
				}),
			},
		},
		{
			title: "序号",
			dataIndex: "id",
			search: false,
		},
		{
			title: "合伙人昵称",
			dataIndex: "shopTitle",
		},
		{
			title: "关联小区",
			dataIndex: "community",
		},
		{
			title: "当日成功",
			dataIndex: "shopCert",
			search: false,
		},
		{
			title: "当日失败",
			dataIndex: "createTime",
			search: false,
		},
		{
			title: "累计成功",
			dataIndex: "phone",
			search: false,
		},
		{
			title: "累计失败",
			dataIndex: "phone",
			search: false,
		},
		{
			title: "累计收益",
			dataIndex: "phone",
			search: false,
		},
		{
			title: "已提现金额",
			dataIndex: "phone",
			search: false,
		},
	];

	// 一体化表格props
	const tablePorps: IntegrationTableProps = {
		rowKey: "id",
		scroll: { x: 1000 },
		columns,
		listProps: {
			url: "/shopInfo/list",
		},
		addProps: {
			url: "/community/add",
			method: "POST",
			paramsHandle: (params: any) => {
				params.communityImage = (
					params?.communityImage?.map((item: any) => item.url) || []
				).join(",");
				return {
					...params,
				};
			},
			modalProps: {
				formProps: {
					labelCol: { span: 8 },
				},
				formItemsHandle: (_: any, vm: any) => {
					// return getFormItems(vm);
				},
			},
		},
	};

	// 初始化加载数据
	useEffect(() => {
		return () => {
			isUnMounted = true;
		};
	}, []);

	return <IntegrationTable {...tablePorps} />;
};

export default Business;
